/************************************************************************************************
 * test examples of 100 interesting program in C
 * test 002.c
 * test: draw cosine and sine graph with "*" and "+"
 ***********************************************************************************************/

#include <stdio.h>
#include <math.h>

/*
 * original problem and solution in book is not quite right
 * so I just code the test
 */

int main()
{
	double y = 0.0;
	int x = 0, m = 0, n = 0;
	for (y = 1.0; y >= 0.0; y -= 0.1)
	{
		m = acos(y)*10;
		n = asin(y)*10;
		for (x = 0; x <= 62; x++)
		{
			if (x == m || x == 62-m) printf("*");
			else if (x == n || x == 31-n) printf("+");
			else printf(" ");
		}
		printf("\n");
	}
        for (; y >= -1.0; y -= 0.1)
        {
                m = acos(y)*10;
                n = asin(y)*10;
                for (x = 0; x <= 62; x++)
                {
                        if (x == m || x == 62-m) printf("*");
                        else if (x == 62+n || x == 31-n) printf("+");
                        else printf(" ");
                }
		printf("\n");
        }
}

